<?php

declare(strict_types=1);

namespace App\Api\Controller;

use App\Api\Middleware\ResponseMiddleware;
use App\Api\Service\CarService;
use App\Model\Car;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\Middlewares;

#[Controller(prefix: 'api'), Middlewares([ResponseMiddleware::class])]
class CarController
{
    /**
     * 车辆列表
     * @param CarService $service
     * @return \Hyperf\Contract\LengthAwarePaginatorInterface
     */
    #[GetMapping('cars')]
    public function index(CarService $service)
    {
        return $service->index();
    }

    /**
     * 车辆详情
     * @param mixed $id
     * @param CarService $service
     * @return Car
     */
    #[GetMapping('cars/{id}')]
    public function show(mixed $id, CarService $service): Car
    {
        return $service->show($id);
    }
}
